<?php
require_once 'conf/conf.php';
require_once 'init.php';

$dataTable  = array(
    "sEcho" => 1,
	"aaData" => array()
);

$aColumns = array( 'id', 'name', 'gender', 'dob' );

$name = $_GET['name'];
$yy   = $_GET['yy'];
$mm   = $_GET['mm'];
$dd   = $_GET['dd'];
$patientHandler = new PatientHandler();
$result = $patientHandler->searchPatientByName($name , $yy , $mm , $dd);

$searchResult = array();
foreach( $result as $row){
    $patientInfo = array();
    $patientInfo[] = $row['hid'];
    $patientInfo[] = "<a href=patient-personal.php?id=".$row['pid'].">".$row['fullName']."</a>";
    $patientInfo[] = $row['sex'];
    $patientInfo[] = $row['dob'];
    array_push($dataTable['aaData'],  $patientInfo);
}
$dataTable['iTotalRecords'] = count($result);
$dataTable['iTotalDisplayRecords'] = count($result);


header("Content-type: text/x-json");

print json_encode($dataTable);

